package com.ymatou.iapi.godfreightmgr.service;

import com.google.common.reflect.TypeToken;
import com.ymatou.iapi.godfreightmgr.parameter.FreightInfoVoBase;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.EnvSetup;

import java.util.List;

/**
*运费模板列表（基本信息）Call
*FreeMaker Template自动生成代码
*/
public class GetTemplateListByIdListCall extends YmatouBaseCall{
	private static String opurl ="api/freight/GetTemplateListByIdList";
	
	public GetTemplateListByIdListCall() {
		super(EnvSetup.getSystemUrl("godfreightmgr_ipai"),opurl,"POST","JSON");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	public List<FreightInfoVoBase> getTemplateList(){
		String sResults=getJsonObject().get("data").getAsJsonObject().get("templateList").getAsJsonArray().toString();
		List<FreightInfoVoBase> freightInfoVoBaseList=(List<FreightInfoVoBase>) FormatUtil.GSONToObject(sResults, new TypeToken<List<FreightInfoVoBase>>(){}.getType());
		return freightInfoVoBaseList;
	}

}